home *** CD-ROM | disk | FTP | other *** search
/ Mac OS 9 Serial Number Archive / SN Archive 2023.11.04.toast / Cracking Texts / Hackintosh Bible v1.1 / Hackintosh Bible v1.1.rsrc / TEXT_130.txt / __headers__.txt next >
Encoding:
Text File  |  1996-08-07  |  9.7 KB  |  163 lines

  1.     Control assignments
  2.  
  3.     control-character C                      Sets control-character to C, where control-character is                      erase, kill, intr (interrupt), quit, eof, eol, swtch                      (switch), start, stop or susp.
  4.  
  5.                       start and stop are available as possible control char-                      acters for the control-character C assignment.
  6.  
  7.                       If C is preceded by a caret (^) (escaped from the                      shell), then the value used is the corresponding con-                      trol character (for example, ^D is a <Ctrl>d; ^? is                      interpreted as DELETE and ^- is interpreted as unde-                      fined).
  8.  
  9. Use the stty -a command to see your current stty settings, and to
  10. determine which one is causing you problems.
  11.  
  12.  
  13. 17. What is ethernet sniffing?
  14.  
  15. Ethernet sniffing is listening (with software) to the raw ethernet
  16. device for packets that interest you.  When your software sees a
  17. packet that fits certain criteria, it logs it to a file.  The most
  18. common criteria for an interesting packet is one that contains words
  19. like "login" or "password."
  20.  
  21. Many ethernet sniffers are available, here are a few that may be on
  22. your system now:
  23.  
  24. OS              Sniffer
  25. ~~              ~~~~~~~
  26. HP/UX           nettl (monitor) & netfmt (display)                nfswatch        /* Available via anonymous ftp           */
  27. Irix            nfswatch        /* Available via anonymous ftp           */                Etherman
  28. SunOS           etherfind                nfswatch        /* Available via anonymous ftp           */
  29. Solaris         snoop
  30. DOS             ETHLOAD         /* Available via anonymous ftp as        */                                /* ethld104.zip                          */                The Gobbler     /* Available via anonymous ftp           */                LanPatrol                LanWatch        Netmon                Netwatch                Netzhack        /* Available via anonymous ftp at        */                                /* mistress.informatik.unibw-muenchen.de */                                /* /pub/netzhack.mac                     */
  31. Macintosh       Etherpeek
  32.  
  33. Here is source code for an ethernet sniffer:
  34.  
  35. /* Esniff.c */
  36.  
  37. #include <stdio.h>
  38. #include <ctype.h>
  39. #include <string.h>
  40.  
  41. #include <sys/time.h>
  42. #include <sys/file.h>
  43. #include <sys/stropts.h>
  44. #include <sys/signal.h>
  45. #include <sys/types.h>
  46. #include <sys/socket.h>
  47. #include <sys/ioctl.h>
  48.  
  49. #include <net/if.h>
  50. #include <net/nit_if.h>
  51. #include <net/nit_buf.h>
  52. #include <net/if_arp.h>
  53.  
  54. #include <netinet/in.h>
  55. #include <netinet/if_ether.h>
  56. #include <netinet/in_systm.h>
  57. #include <netinet/ip.h>
  58. #include <netinet/udp.h>
  59. #include <netinet/ip_var.h>
  60. #include <netinet/udp_var.h>
  61. #include <netinet/in_systm.h>
  62. #include <netinet/tcp.h>
  63. #include <netinet/ip_icmp.h>
  64.  
  65. #include <netdb.h>
  66. #include <arpa/inet.h>
  67.  
  68. #define ERR stderr
  69.  
  70. char    *malloc(); char    *device,        *ProgName,        *LogName; FILE    *LOG; int     debug=0;  #define NIT_DEV     "/dev/nit"
  71. #define CHUNKSIZE   4096        /* device buffer size */
  72. int     if_fd = -1; int     Packet[CHUNKSIZE+32];  void Pexit(err,msg)
  73. int err; char *msg; { perror(msg);  exit(err); }
  74.  
  75. void Zexit(err,msg)
  76. int err; char *msg; { fprintf(ERR,msg);  exit(err); }
  77.  
  78. #define IP          ((struct ip *)Packet)
  79. #define IP_OFFSET   (0x1FFF)
  80. #define SZETH       (sizeof(struct ether_header))
  81. #define IPLEN       (ntohs(ip->ip_len))
  82. #define IPHLEN      (ip->ip_hl)
  83. #define TCPOFF      (tcph->th_off)
  84. #define IPS         (ip->ip_src)
  85. #define IPD         (ip->ip_dst)
  86. #define TCPS        (tcph->th_sport)
  87. #define TCPD        (tcph->th_dport)
  88. #define IPeq(s,t)   ((s).s_addr == (t).s_addr)
  89.  
  90. #define TCPFL(FLAGS) (tcph->th_flags & (FLAGS))
  91.  
  92. #define MAXBUFLEN  (128)
  93. time_t  LastTIME = 0;  struct CREC {     struct CREC *Next,                 *Last;     time_t  Time;              /* start time */     struct in_addr SRCip,                    DSTip;     u_int   SRCport,           /* src/dst ports */             DSTport;     u_char  Data[MAXBUFLEN+2]; /* important stuff :-) */     u_int   Length;            /* current data length */     u_int   PKcnt;             /* # pkts */     u_long  LASTseq; };  struct CREC *CLroot = NULL;  char *Symaddr(ip)
  94. register struct in_addr ip; { register struct hostent *he =      gethostbyaddr((char *)&ip.s_addr, sizeof(struct in_addr),AF_INET);    return( (he)?(he->h_name):(inet_ntoa(ip)) ); }
  95.  
  96. char *TCPflags(flgs)
  97. register u_char flgs; { static char iobuf[8]; #define SFL(P,THF,C) iobuf[P]=((flgs & THF)?C:'-')
  98.  
  99.   SFL(0,TH_FIN, 'F');  SFL(1,TH_SYN, 'S');  SFL(2,TH_RST, 'R');  SFL(3,TH_PUSH,'P');  SFL(4,TH_ACK, 'A');  SFL(5,TH_URG, 'U');  iobuf[6]=0;  return(iobuf); }
  100.  
  101. char *SERVp(port)
  102. register u_int port; { static char buf[10];  register char *p;     switch(port) {     case IPPORT_LOGINSERVER: p="rlogin"; break;     case IPPORT_TELNET:      p="telnet"; break;     case IPPORT_SMTP:        p="smtp"; break;     case IPPORT_FTP:         p="ftp"; break;     default: sprintf(buf,"%u",port); p=buf; break;   }   return(p); }
  103.  
  104. char *Ptm(t)
  105. register time_t *t; { register char *p = ctime(t);  p[strlen(p)-6]=0; /* strip " YYYY\n" */  return(p); }
  106.  
  107. char *NOWtm()
  108. { time_t tm;  time(&tm);  return( Ptm(&tm) ); }
  109.  
  110. #define MAX(a,b) (((a)>(b))?(a):(b))
  111. #define MIN(a,b) (((a)<(b))?(a):(b))
  112.  
  113. /* add an item */
  114. #define ADD_NODE(SIP,DIP,SPORT,DPORT,DATA,LEN) { \  register struct CREC *CLtmp = \        (struct CREC *)malloc(sizeof(struct CREC)); \  time( &(CLtmp->Time) ); \  CLtmp->SRCip.s_addr = SIP.s_addr; \  CLtmp->DSTip.s_addr = DIP.s_addr; \  CLtmp->SRCport = SPORT; \  CLtmp->DSTport = DPORT; \  CLtmp->Length = MIN(LEN,MAXBUFLEN); \  bcopy( (u_char *)DATA, (u_char *)CLtmp->Data, CLtmp->Length); \  CLtmp->PKcnt = 1; \  CLtmp->Next = CLroot; \  CLtmp->Last = NULL; \  CLroot = CLtmp; \
  115. }
  116.  
  117. register struct CREC *GET_NODE(Sip,SP,Dip,DP)
  118. register struct in_addr Sip,Dip; register u_int SP,DP; { register struct CREC *CLr = CLroot;    while(CLr != NULL) {    if( (CLr->SRCport == SP) && (CLr->DSTport == DP) &&        IPeq(CLr->SRCip,Sip) && IPeq(CLr->DSTip,Dip) )            break;    CLr = CLr->Next;  }  return(CLr); }
  119.  
  120. #define ADDDATA_NODE(CL,DATA,LEN) { \ bcopy((u_char *)DATA, (u_char *)&CL->Data[CL->Length],LEN); \ CL->Length += LEN; \
  121. }
  122.  
  123. #define PR_DATA(dp,ln) {    \  register u_char lastc=0; \  while(ln-- >0) { \     if(*dp < 32) {  \        switch(*dp) { \            case '\0': if((lastc=='\r') || (lastc=='\n') || lastc=='\0') \                        break; \            case '\r': \            case '\n': fprintf(LOG,"\n     : "); \                        break; \            default  : fprintf(LOG,"^%c", (*dp + 64)); \                        break; \        } \     } else { \        if(isprint(*dp)) fputc(*dp,LOG); \        else fprintf(LOG,"(%d)",*dp); \     } \     lastc = *dp++; \  } \  fflush(LOG); \
  124. }
  125.  
  126. void END_NODE(CLe,d,dl,msg)
  127. register struct CREC *CLe; register u_char *d; register int dl; register char *msg; {   fprintf(LOG,"\n-- TCP/IP LOG -- TM: %s --\n", Ptm(&CLe->Time));   fprintf(LOG," PATH: %s(%s) =>", Symaddr(CLe->SRCip),SERVp(CLe->SRCport));   fprintf(LOG," %s(%s)\n", Symaddr(CLe->DSTip),SERVp(CLe->DSTport));   fprintf(LOG," STAT: %s, %d pkts, %d bytes [%s]\n",                        NOWtm(),CLe->PKcnt,(CLe->Length+dl),msg);   fprintf(LOG," DATA: ");    { register u_int i = CLe->Length;      register u_char *p = CLe->Data;      PR_DATA(p,i);      PR_DATA(d,dl);    }
  128.  
  129.    fprintf(LOG,"\n-- \n");   fflush(LOG);     if(CLe->Next != NULL)    CLe->Next->Last = CLe->Last;   if(CLe->Last != NULL)    CLe->Last->Next = CLe->Next;   else    CLroot = CLe->Next;   free(CLe); }
  130.  
  131. /* 30 mins (x 60 seconds) */
  132. #define IDLE_TIMEOUT 1800
  133. #define IDLE_NODE() { \  time_t tm; \  time(&tm); \  if(LastTIME<tm) { \     register struct CREC *CLe,*CLt = CLroot; \     LastTIME=(tm+IDLE_TIMEOUT); tm-=IDLE_TIMEOUT; \     while(CLe=CLt) { \       CLt=CLe->Next; \       if(CLe->Time <tm) \           END_NODE(CLe,(u_char *)NULL,0,"IDLE TIMEOUT"); \     } \  } \
  134. }
  135.  
  136. void filter(cp, pktlen)
  137. register char *cp; register u_int pktlen; { register struct ip     *ip; register struct tcphdr *tcph;   { register u_short EtherType=ntohs(((struct ether_header *)cp)->ether_type);     if(EtherType < 0x600) {     EtherType = *(u_short *)(cp + SZETH + 6);     cp+=8; pktlen-=8;   }
  138.  
  139.    if(EtherType != ETHERTYPE_IP) /* chuk it if its not IP */      return; }
  140.  
  141.     /* ugh, gotta do an alignment :-( */ bcopy(cp + SZETH, (char *)Packet,(int)(pktlen - SZETH));   ip = (struct ip *)Packet; if( ip->ip_p != IPPROTO_TCP) /* chuk non tcp pkts */    return; tcph = (struct tcphdr *)(Packet + IPHLEN);   if(!( (TCPD == IPPORT_TELNET) ||       (TCPD == IPPORT_LOGINSERVER) ||       (TCPD == IPPORT_FTP)   )) return;   { register struct CREC *CLm;   register int length = ((IPLEN - (IPHLEN * 4)) - (TCPOFF * 4));   register u_char *p = (u_char *)Packet;     p += ((IPHLEN * 4) + (TCPOFF * 4));   if(debug) {  fprintf(LOG,"PKT: (%s %04X) ", TCPflags(tcph->th_flags),length);  fprintf(LOG,"%s[%s] => ", inet_ntoa(IPS),SERVp(TCPS));  fprintf(LOG,"%s[%s]\n", inet_ntoa(IPD),SERVp(TCPD)); }
  142.  
  143.    if( CLm = GET_NODE(IPS, TCPS, IPD, TCPD) ) {
  144.  
  145.       CLm->PKcnt++;        if(length>0)        if( (CLm->Length + length) < MAXBUFLEN ) {          ADDDATA_NODE( CLm, p,length);        } else {          END_NODE( CLm, p,length, "DATA LIMIT");        }
  146.  
  147.       if(TCPFL(TH_FIN|TH_RST)) {          END_NODE( CLm, (u_char *)NULL,0,TCPFL(TH_FIN)?"TH_FIN":"TH_RST" );      }
  148.  
  149.    } else {
  150.  
  151.       if(TCPFL(TH_SYN)) {         ADD_NODE(IPS,IPD,TCPS,TCPD,p,length);      }
  152.  
  153.    }
  154.  
  155.    IDLE_NODE();   }
  156.  
  157. }
  158.  
  159. /* signal handler */
  160. void death()
  161. { register struct CREC *CLe;      while(CLe=CLroot)        END_NODE( CLe, (u_char *)NULL,0, "SIGNAL");      fprintf(LOG,"\nLog ended at => %s\n",NOWtm());    fflush(LOG);    if(LOG != stdout)        fclose(LOG);    exit(1); }
  162.  
  163.